package com.app.ui.pager.home;

import android.view.LayoutInflater;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.app.ui.activity.base.BaseActivity;
import com.app.ui.pager.BaseViewPager;
import com.wxj.zx.R;

/**
 * 咨询
 * Created by Administrator on 2016/9/7.
 */
public class HomeConsultPager extends BaseViewPager {
    public HomeConsultPager(BaseActivity baseActivity) {
        super(baseActivity);
    }

    private WebView webView;

    @Override
    protected View onViewCreated() {
        View view = LayoutInflater.from(baseActivity).inflate(R.layout.pager_home_consult, null);
        webView = (WebView) view.findViewById(R.id.web_view);
        WebSettings settings = webView.getSettings();
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setBlockNetworkImage(false);
        settings.setJavaScriptEnabled(true);
        settings.setBlockNetworkImage(false);
        //
        webView.setWebViewClient(new WebViewClient() {

            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                view.clearCache(true);
                view.loadUrl(url);
                return true;
            }
        });
        //
        webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {

            }

        });
        String url = "https://ddys-wechat.diandianys.com/WeChat/jkbk/?from=singlemessage&isappinstalled=0#/home";
        webView.loadUrl(url);
        return view;
    }

    public boolean onBack() {
        if (webView.canGoBack()) {
            webView.goBack();
            return true;
        }
        return false;
    }
}
